package com.yd.test;

import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;

import com.alibaba.fastjson.JSONObject;
import com.yd.pojo.AAdmins;
import com.yd.service.IUsersService;
import com.yd.util.ConstateFinalUtil;

public class test extends BastTest
{
	private IUsersService usersService;
	@Before
    public void init(){
    	super.init();
    	this.usersService=(IUsersService) this.ac.getBean("usersService");
    }
	@Test
	public void findOneAdmins(){
		Map<String, Object> condMap=new HashMap<String, Object>();
		condMap.put("phone", "15030581226");
		AAdmins admins=this.usersService.findOneAdmins(condMap);
		ConstateFinalUtil.logger.info("==========="+admins.getEmail()+"===="+admins.getPassword());
	}
	@Test
	public void saveOneAdmins(){
		AAdmins admins=new AAdmins();
		admins.setCreateTime(new Date());
		admins.setLastLoginTime(new Date());
		admins.setUpdateTime(new Date());
		admins.setRoleId(23);
		admins.setEmail("sdfdsf");
		admins.setPassword("23244");
		JSONObject jsonObject=this.usersService.saveOneAdmins(admins);
		ConstateFinalUtil.logger.info("=========="+jsonObject);
	}
	@Test
	public void updateOneAdmins(){
		Map<String, Object> condMap=new HashMap<String, Object>();
		condMap.put("id", 14);
		AAdmins admins=this.usersService.findOneAdmins(condMap);
		admins.setEmail("aaaaaaaaaaaaaaaaa");
		JSONObject jsonObject=this.usersService.updateOneAdmins(admins);
		ConstateFinalUtil.logger.info("=========="+jsonObject);
	}
	@Test
	public void deleteOneAdmins(){
		Map<String, Object> condMap=new HashMap<String, Object>();
		condMap.put("id", 14);
		AAdmins admins=this.usersService.findOneAdmins(condMap);
		JSONObject jsonObject=this.usersService.deleteOneAdmins(admins);
		ConstateFinalUtil.logger.info("=========="+jsonObject);
		
	}
	@Test
	public void aa(){
		Map<String, Object> condMap=new HashMap<String, Object>();
		List<AAdmins> admins=this.usersService.findCondListAdmins(condMap);
		for (Iterator iterator = admins.iterator(); iterator.hasNext();)
		{
			AAdmins aAdmins = (AAdmins) iterator.next();
			System.out.println("=========="+aAdmins.getEmail());
		}
	}
	@Test
	public void tess(){
		String str=ConstateFinalUtil.INFO.getString("0");
		System.out.println(str);
	}
	
}
